package com.zw.yzk.kabu.mapper;

import com.zw.yzk.kabu.data.network.entity.SkinPackageEntity;
import com.zw.yzk.kabu.model.SkinModel;

import javax.inject.Inject;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by skydar on 2017/4/14.
 */

public class SkinMapper {

    @Inject
    public SkinMapper() {

    }

    public SkinModel transfer(SkinPackageEntity entity) {
        SkinModel model = new SkinModel();
        SkinPackageEntity.Result skin = entity.result;

        model.setId(skin.id);
        model.setName(skin.name);
        model.setCoverPath(skin.coverPath);
        model.setSourceUrl(skin.sourceUrl);
        model.setDatetTime(skin.datetTime);
        model.setOriginalPrice(skin.originalPrice);
        model.setDiscountedPrice(skin.discountedPrice);
        model.setDownloads(skin.downloads);
        model.setIntroduce(skin.introduce);

        List<SkinModel.SkinIntroduceModel> models = new ArrayList<>();
        for(int i=0; i<skin.introduces.size(); i++){
            SkinPackageEntity.Result.SkinIntroduceEntity n = skin.introduces.get(i);
            SkinModel.SkinIntroduceModel m = new SkinModel.SkinIntroduceModel();
            m.setId(n.id);
            m.setImg(n.img);
            models.add(m);
        }
        model.setIntroduces(models);

        return model;
    }
}
